<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:o="http://openfaces.org/"
	xmlns:rich="http://richfaces.org/rich">

	<rich:modalPanel id="editPanel" autosized="true" zindex="10500">
		<f:facet name="header">
			<h:outputText value="Editar" rendered="#{transactionHelper.editMode == '1'}"/>
			<h:outputText value="Agregar" rendered="#{transactionHelper.editMode == '0'}"/>
		</f:facet>

		<div align="center">
			<h:form>
				<a4j:jsFunction name="refreshInfo" reRender="info">
				</a4j:jsFunction>
				<h:panelGroup id="info">
					<h:panelGrid columns="2">
						<h:outputText value="#{messages['intro2.file']}:"/>
						<h:panelGroup>
							<h:outputText rendered="#{transactionHelper.selectedFile != null}" id="nombreArchivo" value="#{transactionHelper.selectedFile.fileName}"/>
							<rich:fileUpload rendered="#{transactionHelper.selectedFile == null}" acceptedTypes="gif,jpg,png,pdf,doc,xls"
									allowFlash="false" autoclear="false" noDuplicate="true"
									maxFilesQuantity="1" immediateUpload="true" clearAllControlLabel="" clearControlLabel=""
									fileUploadListener="#{transactionHelper.attachFileListener}"
									listHeight="80" listWidth="200" addControlLabel="Seleccionar"
									onuploadcomplete="refreshInfo();" ontyperejected="alert('Formato de archivo no soportado. Debe ser jpg, pdf, tiff o png.')">
								<a4j:support event="onuploadcomplete" reRender="info"/>
							</rich:fileUpload>
						</h:panelGroup>
					</h:panelGrid>
					
					<h:panelGrid columns="2" rendered="#{transactionHelper.selectedFile != null}">
						<h:outputText value="#{messages['txt.type']}" />
						<h:selectOneMenu value="#{transactionHelper.selectedFile.adminSourceType}" converter="#{uiConverters.administrativeSourceType}">
							<f:selectItems
								noSelectionValue=""
								value="#{uiConverters.administrativeSourceType.valueList}">
							</f:selectItems>
						</h:selectOneMenu>
						
						<h:outputText value="#{messages['intro2.description']}:"/>
						<h:panelGroup id="fileDescr">
							<h:inputTextarea value="#{transactionHelper.selectedFile.descripcion}"
							cols="30" rows="5"/>
						</h:panelGroup>
					</h:panelGrid>
				</h:panelGroup>
				
				<br />
				<br />
	
				<a4j:commandButton
					value="#{messages['button.ok']}"
					action="#{transactionHelper.acceptSelectedFile}"
					oncomplete="#{rich:component('editPanel')}.hide()"
					reRender="tabla">
				</a4j:commandButton>
				<o:commandButton
					value="#{messages['button.close']}"
					type="button"
					onclick="#{rich:component('editPanel')}.hide()">
				</o:commandButton>
			</h:form>
		</div>
	</rich:modalPanel>
</ui:composition>
